﻿namespace NJQuery {
	using System;
	using System.Web.UI;
	using System.ComponentModel;

	/// <summary>
	/// Provides core functionality that can be extended by various specific animation script-generating controls to generate blocks of client jQuery animation script.
	/// </summary>
	public abstract class AnimationDef : ScriptDef {

		//TODO: Decide if this middle abstract between AccordionAnimationDef and ScriptDef is even necessary.  It seems the effects framework might have made this methodology's days numbered.

		#region Constants

		private const string defaultName = "custom";

		#endregion


		#region Constructors

		/// <summary>
		/// Initializes a new instance of the <see cref="AnimationDef"/> class.
		/// </summary>
		protected AnimationDef() { }

		#endregion


		#region Properties

		/// <summary>
		/// Gets or sets the function name assigned to the custom animation script.
		/// </summary>
		[DefaultValue(defaultName), Category("Misc")]
		public virtual string Name {
			get { return ViewState["Name"] as string ?? "custom"; }
			set {
				if(value == null) throw new ArgumentNullException("value");
				if(value.Length == 0) throw new ArgumentException("Value is required.", "value");

				//TODO: Validate name is a valid javascript function

				ViewState["Name"] = value;
			}
		}

		#endregion


	}

}